home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 944 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: harden.demon.co.uk!mark
  2. From: Mark Harden <mark@harden.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Array of pointers to a tree structure ?
  5. Date: Wed, 10 Jan 1996 12:16:53 +0000
  6. Organization: Not an organisation
  7. Distribution: world
  8. Message-ID: <nxRvQDA1468wEw$$@harden.demon.co.uk>
  9. References: <4d067t$9lc@hermes.fundp.ac.be>
  10. NNTP-Posting-Host: harden.demon.co.uk
  11. X-NNTP-Posting-Host: harden.demon.co.uk
  12. MIME-Version: 1.0
  13. X-Newsreader: Turnpike Version 1.10 <RMdKwNiDEBO6d87vIffee+0s$n>
  14.  
  15. In article <4d067t$9lc@hermes.fundp.ac.be>, Francisco Melo Ledermann
  16. <fmelo@biq.fundp.ac.be> writes
  17. >Hi Colleagues, I have been learning C language just from one month ago 
  18. >and I don't know too much about this language. I have a problem with the 
  19. >assignment of pointers in an array of pointers with a specifical defined 
  20. >structure. For example:
  21. >
  22. >
  23. >/* BOXES STRUCTURE FOR THE CONSTRUCTION OF A TREE */
  24. >
  25. >struct boxes {
  26. >              int number;
  27. >              struct boxes *pointer_1;
  28. >              struct boxes *pointer_2;
  29. >              struct boxes *pointer_3;
  30. >             }
  31. >
  32. >/* ARRAY OF POINTERS TO BOXES STRUCTURE FOR MANAGE */
  33. >/* SOME BRANCHES OF THE TREE                       */
  34. >
  35. >struct boxes array_pointers [15];
  36.  
  37. Should be "strut boxes *array_pointers [15];" otherwise you are defining
  38. an array of structures.
  39.  
  40. >Supose that I have the array of pointers already defined, with every 
  41. >pointer pointing to a boxes structure and every boxes structure 
  42. >contains only the integer number defined. In this moment I would like 
  43. >to define the three pointers in every box in the way of these pointers 
  44. >point to another element in the array. I have tried statements like 
  45. >this with out success:
  46.  
  47. This is quite advanced stuff.
  48.  
  49. I do not quite understand what you want to do.  The pointers defined in
  50. the structure are defined to pint to the structure itself NOT the array
  51. or an element of it.
  52.  
  53. To set "number" in the structure pointed to by array element 3 to 13 you
  54. would :-
  55.  
  56.         *array_pointers [3]->number = 13;
  57.  
  58. To set "pointer_1" in the structure pointed to be array element 3 to
  59. that pointed to by array element 4 you would :-
  60.  
  61.         *array_pointers [3]->pointer_1 = array_pointers [4]; 
  62.  
  63. I hope this helps.  If not please give more details.  It is also worth
  64. looking at the FAQ as it deals quite well with pointers and arrays.
  65.  
  66.  
  67. >                    Francisco Melo Ledermann                        
  68. >
  69. >mailto:fmelo@biq.fundp.ac.be 
  70. >
  71. >http://biq-pc1.biq.fundp.ac.be/index.html    
  72.  
  73. -- 
  74. Mark Harden
  75.